<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var userName = "张三";
    /* 在JavaScript执行中，使用变量时逐级
    作用域来查找变量，JS中作用域是以函数为单位的
    */
   function showName(){
       var userName = "lisi";
        (function(){
            var userName = "wangwu";
            console.log(userName);
        })();
        console.log(userName);
   }
   showName();
    console.log(userName);
</script>
</html>